Write a C# Sharp program to create a new list from a given list of strings where each element has "#" added at the beginning and end position

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to create a new list from a given list of strings where each element has "#" added at the beginning and end position

Sample Output:

#1# #2# #3# #4#

الأجوبة

using System;
using System.Collections.Generic;
using System.Linq;

namespace exercises
{
   class Program
    {       
        static void Main(string[] args)
        {         
           List mylist = test(new List(new string[] { "1", "2", "3" , "4" }));                  
           foreach(var i in mylist)
            {
               Console.Write(i.ToString()+" ");
            }     
        }                  
        public static List test(List nums_str)
          {
            IEnumerable s = nums_str.Select(x => "#" + x + "#");
            return s.ToList();
          }    
    } 
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...